<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<title>API: utils   tree.js  (YUI Library)</title>

	<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1316139452.1" />
	<link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1316139452.1" />

    <script type="text/javascript" src="assets/api-js?stamp=1316139452.1"></script>
    <script type="text/javascript" src="assets/ac-js?stamp=1316139452.1"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">
	<div id="hd">
        <h1><a href="http://developer.yahoo.com/yui/" title="g-javascript-lib">g-javascript-lib</a></h1>
        <h3>utils&nbsp; <span class="subtitle">1.0.0</span></h3>
        <a href="./index.html" title="g-javascript-lib">g-javascript-lib</a> 
            &gt; <a href="./module_utils.html" title="utils">utils</a>
                
                 &gt; tree.js (source view) 
        <form onsubmit="return false">
            <div id="propertysearch">
                Search: <input autocomplete="off" id="searchinput" />
                <div id="searchresults">
                    &nbsp;
                </div>
            </div>
        </form>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
                <fieldset>
                    <legend>Filters</legend>
                <span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
                <span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
                <span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
                </fieldset>
            </form>

                    <div id="srcout">
                        <style>
                            #doc3 .classopts { display:none; }
                        </style>
<div class="highlight"><pre><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>

	<span class="cm">/**</span>
<span class="cm">	 * @namespace Utils</span>
<span class="cm">	 * @class TreeNode</span>
<span class="cm">	 */</span>
	<span class="nx">TreeNode</span> <span class="o">=</span> <span class="nx">G</span><span class="p">.</span><span class="nx">GClass</span><span class="p">(</span><span class="s1">&#39;Utils&#39;</span><span class="p">,</span> <span class="s1">&#39;TreeNode&#39;</span><span class="p">);</span>

	<span class="cm">/**</span>
<span class="cm">	 * Constructure of TreeNode</span>
<span class="cm">	 * @method __init</span>
<span class="cm">	 */</span>
	<span class="nx">TreeNode</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__init</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">id</span><span class="p">,</span> <span class="nx">data</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">data</span> <span class="o">=</span> <span class="nx">data</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">id</span><span class="p">;</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">childNodes</span> <span class="o">=</span> <span class="p">{};</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">childCount</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">path</span> <span class="o">=</span> <span class="p">[</span><span class="nx">id</span><span class="p">];</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">father</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="nx">TreeNode</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">toString</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">id</span><span class="p">;</span> <span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Dump the whole tree to a string to list of all node&#39;s full path.</span>
<span class="cm">	 * @method dump</span>
<span class="cm">	 */</span>
	<span class="nx">TreeNode</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">dump</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
		<span class="kd">var</span> <span class="nx">str</span><span class="p">;</span>
		<span class="nx">str</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">get_fullname</span><span class="p">();</span>
		<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">n</span>  <span class="k">in</span> <span class="k">this</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">str</span> <span class="o">+=</span> <span class="s2">&quot;, &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">[</span><span class="nx">n</span><span class="p">].</span><span class="nx">dump</span><span class="p">();</span>
		<span class="p">}</span>
		<span class="k">return</span> <span class="nx">str</span><span class="p">;</span>
	<span class="p">}</span>


	<span class="cm">/**</span>
<span class="cm">	 * Get deep in tree.</span>
<span class="cm">	 * @method get_deep</span>
<span class="cm">	 * @return {integer} the deep of the node in tree. The root node has a deep of 0.</span>
<span class="cm">	 */</span>
	<span class="nx">TreeNode</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">get_deep</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
		<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">path</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Get child node amount.</span>
<span class="cm">	 * @method get_child_count</span>
<span class="cm">	 * @return {integer}</span>
<span class="cm">	 */</span>
	<span class="nx">TreeNode</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">get_child_count</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
		<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">childCount</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Get the father node.</span>
<span class="cm">	 * @method get_father</span>
<span class="cm">	 * @return {TreeNode} </span>
<span class="cm">	 */</span>
	<span class="nx">TreeNode</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">get_father</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
		<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">father</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Get the fullname to represet the position in tree.</span>
<span class="cm">	 * @method get_fullname </span>
<span class="cm">	 * @return {string} </span>
<span class="cm">	 */</span>
	<span class="nx">TreeNode</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">get_fullname</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
		<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">);</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Add a child node.</span>
<span class="cm">	 * @method append_child</span>
<span class="cm">	 */</span>
	<span class="nx">TreeNode</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">append_child</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">node</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">node</span><span class="p">.</span><span class="nx">id</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">.</span><span class="nx">propertyIsEnumerable</span><span class="p">(</span><span class="nx">id</span><span class="p">))</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">[</span><span class="nx">id</span><span class="p">]</span> <span class="o">=</span> <span class="nx">node</span><span class="p">;</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">childCount</span> <span class="o">+=</span> <span class="mi">1</span><span class="p">;</span>
			<span class="nx">node</span><span class="p">.</span><span class="nx">__set_path</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">path</span><span class="p">);</span>
			<span class="nx">node</span><span class="p">.</span><span class="nx">father</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
		<span class="p">}</span>
	<span class="p">}</span>


	<span class="cm">/**</span>
<span class="cm">	 * Remove child node</span>
<span class="cm">	 * @method remove_child</span>
<span class="cm">	 */</span>
	<span class="nx">TreeNode</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">remove_child</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sub</span><span class="p">)</span> <span class="p">{</span>
		<span class="c1">// Todo...</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Search the node with the given full path</span>
<span class="cm">	 *</span>
<span class="cm">	 * @method search</span>
<span class="cm">	 * @param fullname {string}</span>
<span class="cm">	 *</span>
<span class="cm">	 */</span>
	<span class="nx">TreeNode</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">search</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">fullname</span><span class="p">)</span> <span class="p">{</span>
		<span class="kd">var</span> <span class="nx">arr</span> <span class="o">=</span> <span class="nx">fullname</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">);</span>
		<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
		<span class="k">for</span> <span class="p">(</span><span class="nx">n</span> <span class="k">in</span> <span class="nx">arr</span><span class="p">)</span> <span class="p">{</span>
			<span class="kd">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">arr</span><span class="p">[</span><span class="nx">n</span><span class="p">];</span>
			<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">.</span><span class="nx">propertyIsEnumerable</span><span class="p">(</span><span class="nx">id</span><span class="p">))</span> <span class="p">{</span>
				<span class="nx">t</span> <span class="o">=</span> <span class="nx">t</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">[</span><span class="nx">id</span><span class="p">];</span>
			<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
				<span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
			<span class="p">}</span>
		<span class="p">}</span>
		<span class="k">return</span> <span class="nx">t</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Disconnect the node from the tree. The path node and all of it&#39;s child nodes</span>
<span class="cm">	 * will be updated.</span>
<span class="cm">	 * @function disconnect</span>
<span class="cm">	 */</span>
	<span class="nx">TreeNode</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">disconnect</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">father</span> <span class="o">==</span> <span class="kc">null</span><span class="p">)</span>	<span class="k">return</span><span class="p">;</span>
		
		<span class="kd">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">id</span><span class="p">;</span>
		<span class="k">delete</span> <span class="k">this</span><span class="p">.</span><span class="nx">father</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">[</span><span class="nx">id</span><span class="p">];</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">father</span><span class="p">.</span><span class="nx">childCount</span> <span class="o">-=</span> <span class="mi">1</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">father</span><span class="p">.</span><span class="nx">path</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">__bubble_up</span><span class="p">(</span><span class="nx">i</span><span class="p">);</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">father</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Change the position of the nodeDisconnect the node from it&#39;s father and </span>
<span class="cm">	 * @function move</span>
<span class="cm">	 * @param father {TreeNode} The new father of the node will be conected to.</span>
<span class="cm">	 */</span>
	<span class="nx">TreeNode</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">move</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">father</span><span class="p">)</span> <span class="p">{</span>

		<span class="k">if</span> <span class="p">(</span><span class="nx">father</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s2">&quot;&quot;</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">id</span><span class="p">)</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">)</span>	<span class="p">{</span>
			<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
		<span class="p">}</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">father</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">disconnect</span><span class="p">();</span>
		<span class="p">}</span>
		<span class="nx">father</span><span class="p">.</span><span class="nx">append_child</span><span class="p">(</span><span class="k">this</span><span class="p">);</span>
	<span class="p">}</span>


	<span class="cm">/*</span>
<span class="cm">	 * Decrease the depth of path</span>
<span class="cm">	 */</span>
	<span class="nx">TreeNode</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__bubble_up</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">lvl</span><span class="p">)</span> <span class="p">{</span>
		<span class="kd">var</span> <span class="nx">len</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">path</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span>

		<span class="k">if</span> <span class="p">(</span><span class="nx">len</span> <span class="o">&gt;=</span> <span class="nx">lvl</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">path</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nx">lvl</span><span class="p">);</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">path</span> <span class="o">=</span> <span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">id</span><span class="p">];</span>
		<span class="p">}</span>
		<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">n</span> <span class="k">in</span> <span class="k">this</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">[</span><span class="nx">n</span><span class="p">].</span><span class="nx">__bubble_up</span><span class="p">(</span><span class="nx">lvl</span><span class="p">);</span>
		<span class="p">}</span>
	<span class="p">}</span>


	<span class="nx">TreeNode</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__set_path</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">path</span><span class="p">)</span> <span class="p">{</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">path</span> <span class="o">=</span> <span class="nx">path</span><span class="p">.</span><span class="nx">concat</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">path</span><span class="p">);</span>
		<span class="k">for</span> <span class="p">(</span><span class="nx">n</span> <span class="k">in</span> <span class="k">this</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">[</span><span class="nx">n</span><span class="p">].</span><span class="nx">__set_path</span><span class="p">(</span><span class="nx">path</span><span class="p">);</span>
		<span class="p">}</span>
	<span class="p">}</span>


	<span class="nx">Tree</span> <span class="o">=</span> <span class="nx">G</span><span class="p">.</span><span class="nx">GClass</span><span class="p">(</span><span class="s1">&#39;Utils&#39;</span><span class="p">,</span> <span class="s1">&#39;Tree&#39;</span><span class="p">);</span>
	<span class="nx">Tree</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__init</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">nodeType</span><span class="p">,</span> <span class="nx">subs</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_nodeType</span> <span class="o">=</span> <span class="nx">nodeType</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="nx">subs</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">get_subs</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">data</span><span class="p">)</span> <span class="p">{</span><span class="k">return</span> <span class="nx">data</span><span class="p">[</span><span class="nx">subs</span><span class="p">]};</span>
		<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="nx">subs</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">get_subs</span> <span class="o">=</span> <span class="nx">subs</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">get_subs</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">data</span><span class="p">)</span> <span class="p">{</span><span class="k">return</span> <span class="nx">data</span><span class="p">.</span><span class="nx">subs</span><span class="p">};</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="nx">Tree</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">create_node</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">data</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="k">return</span> <span class="k">new</span> <span class="k">this</span><span class="p">.</span><span class="nx">_nodeType</span><span class="p">(</span><span class="nx">data</span><span class="p">);</span>
	<span class="p">}</span>

	<span class="nx">Tree</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">seek_in_subs</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">data</span><span class="p">,</span> <span class="nx">indx</span><span class="p">)</span> 
	<span class="p">{</span> 
		<span class="k">this</span><span class="p">.</span><span class="nx">_subIndex</span> <span class="o">=</span> <span class="nx">indx</span> <span class="o">||</span> <span class="mi">0</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="nx">Tree</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">step_in_subs</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">data</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_subIndex</span> <span class="o">&gt;=</span> <span class="k">this</span><span class="p">.</span><span class="nx">data</span><span class="p">.</span><span class="nx">subs</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
		<span class="p">}</span>
		<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">data</span><span class="p">.</span><span class="nx">subs</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">_subIndex</span><span class="o">++</span><span class="p">];</span>
	<span class="p">}</span>


	<span class="nx">Tree</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">set_root</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">root</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">root</span> <span class="o">=</span> <span class="nx">root</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="nx">Tree</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">import_tree_data</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">data</span><span class="p">,</span> <span class="nx">root</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">root</span> <span class="o">=</span> <span class="nx">root</span> <span class="o">||</span> <span class="kc">null</span><span class="p">;</span>

		<span class="kd">var</span> <span class="nx">node</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">create_node</span><span class="p">(</span><span class="nx">data</span><span class="p">);</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">root</span> <span class="o">==</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">root</span> <span class="o">=</span> <span class="nx">node</span><span class="p">;</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="nx">root</span><span class="p">.</span><span class="nx">append_child</span><span class="p">(</span><span class="nx">node</span><span class="p">);</span>
		<span class="p">}</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">seek_in_subs</span><span class="p">(</span><span class="nx">data</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>
		<span class="k">for</span> <span class="p">(</span><span class="nx">s</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">step_in_subs</span><span class="p">();</span> <span class="nx">s</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">;</span> <span class="nx">s</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">step_in_subs</span><span class="p">())</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">import_tree_data</span><span class="p">(</span><span class="nx">s</span><span class="p">,</span> <span class="nx">node</span><span class="p">);</span>
		<span class="p">}</span>
	<span class="p">}</span>
<span class="p">})();</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div id="moduleList" class="module">
                        <h4>Modules</h4>
                        <ul class="content">
                                <li class=""><a href="module_base.html" title="base">base</a></li>
                                <li class=""><a href="module_svg.html" title="svg">svg</a></li>
                                <li class=""><a href="module_test.html" title="test">test</a></li>
                                <li class="selected"><a href="module_utils.html" title="utils">utils</a></li>
                                <li class=""><a href="module_widget.html" title="widget">widget</a></li>
                        </ul>
                    </div>

                    <div id="classList" class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="Test.Array.html" title="Test.Array">Test.Array</a></li>
                                <li class=""><a href="Test.List.html" title="Test.List">Test.List</a></li>
                                <li class=""><a href="Test.ListNode.html" title="Test.ListNode">Test.ListNode</a></li>
                                <li class=""><a href="Utils.TreeNode.html" title="Utils.TreeNode">Utils.TreeNode</a></li>
                                <li class=""><a href="widget.DataSource.html" title="widget.DataSource">widget.DataSource</a></li>
                                <li class=""><a href="widget.DataSourceArray.html" title="widget.DataSourceArray">widget.DataSourceArray</a></li>
                        </ul>
                    </div>

                    <div id="fileList" class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class=""><a href="barview.js.html" title="barview.js">barview.js</a></li>
                                <li class=""><a href="datasource.js.html" title="datasource.js">datasource.js</a></li>
                                <li class=""><a href="dgrid.js.html" title="dgrid.js">dgrid.js</a></li>
                                <li class=""><a href="list.js.html" title="list.js">list.js</a></li>
                                <li class="selected"><a href="tree.js.html" title="tree.js">tree.js</a></li>
                                <li class=""><a href="xml.js.html" title="xml.js">xml.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2011 Yahoo! Inc. All rights reserved.
	</div>
</div>
<script type="text/javascript">
    ALL_YUI_PROPS = [{"url": "Test.List.html#method_append", "access": "", "host": "Test.List", "type": "method", "name": "append"}, {"url": "Utils.TreeNode.html#method_append_child", "access": "", "host": "Utils.TreeNode", "type": "method", "name": "append_child"}, {"url": "Test.List.html#method_clear", "access": "", "host": "Test.List", "type": "method", "name": "clear"}, {"url": "Utils.TreeNode.html#method_disconnect", "access": "", "host": "Utils.TreeNode", "type": "method", "name": "disconnect"}, {"url": "Utils.TreeNode.html#method_dump", "access": "", "host": "Utils.TreeNode", "type": "method", "name": "dump"}, {"url": "Utils.TreeNode.html#method_get_child_count", "access": "", "host": "Utils.TreeNode", "type": "method", "name": "get_child_count"}, {"url": "widget.DataSourceArray.html#method_get_data", "access": "", "host": "widget.DataSourceArray", "type": "method", "name": "get_data"}, {"url": "Utils.TreeNode.html#method_get_deep", "access": "", "host": "Utils.TreeNode", "type": "method", "name": "get_deep"}, {"url": "Utils.TreeNode.html#method_get_father", "access": "", "host": "Utils.TreeNode", "type": "method", "name": "get_father"}, {"url": "Utils.TreeNode.html#method_get_fullname", "access": "", "host": "Utils.TreeNode", "type": "method", "name": "get_fullname"}, {"url": "widget.DataSourceArray.html#method_get_total", "access": "", "host": "widget.DataSourceArray", "type": "method", "name": "get_total"}, {"url": "Test.List.html#method_has_only_one", "access": "", "host": "Test.List", "type": "method", "name": "has_only_one"}, {"url": "Utils.TreeNode.html#method___init", "access": "", "host": "Utils.TreeNode", "type": "method", "name": "__init"}, {"url": "Test.List.html#method_insert", "access": "", "host": "Test.List", "type": "method", "name": "insert"}, {"url": "Test.Array.html#method_insertAt", "access": "", "host": "Test.Array", "type": "method", "name": "insertAt"}, {"url": "Test.List.html#method_is_empty", "access": "", "host": "Test.List", "type": "method", "name": "is_empty"}, {"url": "Utils.TreeNode.html#method_move", "access": "", "host": "Utils.TreeNode", "type": "method", "name": "move"}, {"url": "Test.List.html#method_remove", "access": "", "host": "Test.List", "type": "method", "name": "remove"}, {"url": "Test.Array.html#method_removeAt", "access": "", "host": "Test.Array", "type": "method", "name": "removeAt"}, {"url": "Utils.TreeNode.html#method_remove_child", "access": "", "host": "Utils.TreeNode", "type": "method", "name": "remove_child"}, {"url": "Test.List.html#method_search", "access": "", "host": "Test.List", "type": "method", "name": "search"}, {"url": "Utils.TreeNode.html#method_search", "access": "", "host": "Utils.TreeNode", "type": "method", "name": "search"}, {"url": "widget.DataSourceArray.html#method_step_in_page", "access": "", "host": "widget.DataSourceArray", "type": "method", "name": "step_in_page"}];
</script>
</body>
</html>
